package com.gxa.guahao01.controller;

import com.gxa.guahao01.pojo.HuanZheJiuZhenKa;
import com.gxa.guahao01.service.HuanZheJiuZhenKaServiceImpl;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;

/**
 * 患者就诊卡(HuanZheJiuZhenKa)表控制层
 *
 * @author xyc
 * @since 2021-03-16 16:52:18
 * @version 1.0
 */
@RestController
@RequestMapping("huanZheJiuZhenKa")
@Api(value = "患者就诊卡(HuanZheJiuZhenKa)管理",tags = "患者就诊卡(HuanZheJiuZhenKa)管理接口API")
@ApiResponses({
        @ApiResponse(code=400,message="请求参数不完整或者错误"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方式不正确，比如后台接收是post，但前端请求的是get"),
        @ApiResponse(code=406,message="页面地址和接口名冲突"),
        @ApiResponse(code=415,message="请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code=500,message="后台服务逻辑错误")
})
public class HuanZheJiuZhenKaController {
    /**
     * 服务对象
     */
    @Resource
    private HuanZheJiuZhenKaServiceImpl huanZheJiuZhenKaServiceImpl;

    /**
     * 查询所有数据
     * @return 返回所有数据
     */
    @GetMapping("chaXunAll")
    @ApiOperation(value = "查询所有患者就诊卡数据接口",notes = "查询所有数据接口",httpMethod = "GET")
    public Map<String, Object> chaXunAll() {
        return this.huanZheJiuZhenKaServiceImpl.chaXunAll();
    }

    
    /**
     * 通过主键更新单条数据
     *
     * @param huanZheJiuZhenKa 一个数据库对应的POJO数据对象
     * @return 单条数据
     */
    @PostMapping("gengXinById")
    @ApiOperation(value = "通过六位数卡号更新一个患者就诊卡的接口",notes = "传递卡号及需要被修改的值",httpMethod = "POST")
    public Map<String, Object> gengXinById(@RequestBody @ApiParam(name = "huanZheJiuZhenKa",value = "pojo模型",required = true) HuanZheJiuZhenKa huanZheJiuZhenKa) {
        return this.huanZheJiuZhenKaServiceImpl.gengXinById(huanZheJiuZhenKa);
    }
    /**
     * 通过主键查询单条数据
     *
     * @param huanZheKaHao 一个数据库对应的POJO数据对象
     * @return 单条数据
     */
    @GetMapping("chaXunByKaHao")
    @ApiOperation(value = "通过六位数卡号或者身份证号,或者电话、名字、时间范围查询一个患者就诊卡数据的接口",notes = "开始时间和结束时间要么都传，要么都不传",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "huanZheKaHao", value = "患者六位数卡号",
                    required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "shenFenZheng", value = "患者身份证号",
                    required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "xingMing", value = "患者姓名",
                    required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "shouJiHao", value = "患者电话号码",
                    required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "kaiShiShiJian", value = "范围时间查询的开始时间,格式为1997/03/30或1997-03-30或1997:03:30",
                    required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "jieShuShiJian", value = "范围时间查询的结束时间",
                    required = false, dataType = "String", paramType = "query")
    })
    public Map<String, Object> chaXunByKaHao(@RequestParam(name = "huanZheKaHao",required = false) String huanZheKaHao,
                                             @RequestParam(name = "shenFenZheng",required = false) String shenFenZheng,
                                             @RequestParam(name = "xingMing",required = false) String xingMing,
                                             @RequestParam(name = "shouJiHao",required = false) String shouJiHao,
                                             @RequestParam(name = "kaiShiShiJian",required = false) String kaiShiShiJian,
                                             @RequestParam(name = "jieShuShiJian",required = false) String jieShuShiJian
    ) {
        return this.huanZheJiuZhenKaServiceImpl.chaXunByKaHao(huanZheKaHao,shenFenZheng,xingMing,shouJiHao,kaiShiShiJian,jieShuShiJian);
    }
    
    /**
     * 通过一个pojo对象新增单条数据
     *
     * @param huanZheJiuZhenKa 一个数据库对应的POJO数据对象
     * @return 返回插入的主键id
     */
//    @PostMapping("xinZeng")
//    @ApiOperation(value = "根据完整记录新增一个患者就诊卡的接口",notes = "六位数卡号和姓名必传，id勿传",httpMethod = "POST")
//    public Map<String, Object> xinZeng(@RequestBody @ApiParam(name = "huanZheJiuZhenKa",value = "pojo模型",required = true) HuanZheJiuZhenKa huanZheJiuZhenKa) {
//        return this.huanZheJiuZhenKaServiceImpl.xinZeng(huanZheJiuZhenKa);
//    }

}